﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TTEngine
{
    public abstract class TaggedObject
    {
        //string identifier
        public virtual string ObjectName
        {
            get
            {
                return GetType().Name;
            }
        }

        //tag support
        public void AddTag(string tag)
        {
            if (_tags == null)
                _tags = new List<string>();
            tag = tag.ToUpper();
            if (!_tags.Contains(tag))
                _tags.Add(tag);
        }
        public void RemoveTag(string tag)
        {
            if (_tags == null)
                return;
            tag = tag.ToUpper();
            if (_tags.Contains(tag))
                _tags.Remove(tag);
        }

        //also considered to "have" the tag if the ObjectName is equal to the tag
        public bool HasTag(string tag)
        {
            tag = tag.ToUpper();
            if (ObjectName.ToUpper() == tag)
                return true;
            if (_tags == null)
                return false;
            return _tags.Contains(tag);
        }

        //private members
        private List<string> _tags = null;
    }
}
